﻿function changeImg() {
    var imgSrc = $("#imgObj");
    var src = imgSrc.attr("src");
    //alert(src);
    imgSrc.attr("src", chgUrl(src));
}
//时间戳   
//为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳   
function chgUrl(url) {
    var timestamp = (new Date()).valueOf();

    var key = "timestamp";
    var idx = url.indexOf(key);
    if (idx == -1) {
        if (url.indexOf("?") == -1) {
            url = url + "?";
        }
        else {
            url = url + "&";
        }
        url = url + key + "=" + timestamp;
    }
    else {
        url = url.substring(0, idx + key.length + 1) + timestamp
    }
    return url;
}

//验证是否正确
function isRightCode() {
    var code = $("#veryCode").val();
    if (code == "") {
        return;
    }
    $.ajax({
        type: "POST",
        url: "app/ValidateKey.ashx?chknumber=" + code,
        data: code,
        success: function (data) {
            switch (data) {
                case "1":
                    //alert("right");
                    break;
                case "0":
                    alert("验证码错误");
                    $("#veryCode").focus().attr("value", "");
                    break;
            }
        }
    });
}